package com.jiutianniao.p2p.acctrans.core.dal.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

import com.jiutianniao.p2p.acctrans.core.dal.model.AccountDO;
import com.jiutianniao.p2p.base.dao.BaseMapper;

public interface AccountDao extends BaseMapper {

	@Insert("insert into account(account_no,user_id,create_operator,last_modified_operator,account_type,currency,balance,credit_amount,freeze_amount,last_modified_dt,enabled_status,create_dt,repeat_password_error_times,customer_id,alias_name,account_title,balance_direction,deposit_amount,ctu_amount,system_amount)"
			+ " values(#{accountNo},#{userId},#{createOperator},#{lastModifiedOperator},#{accountType},#{currency},#{balance.cent},#{creditAmount.cent},#{freezeAmount.cent},#{lastModifiedDt},#{enabledStatus},#{createDt},#{repeatPasswordErrorTimes},#{customerId},#{aliasName},#{accountTitle},#{balanceDirection},#{depositAmount.cent},#{ctuAmount.cent},#{systemAmount.cent})")
	void create(AccountDO accountDO);

	@Update("update account set balance=#{balance.cent} where account_no = #{accountNo}")
	int updateBalance(AccountDO accountDO);

	@Update("update account set balance=#{balance.cent},freeze_amount=#{freezeAmount.cent} where account_no = #{accountNo}")
	int updateBalanceAndFreeze(AccountDO accountDO);

	AccountDO getByAccountNo(String accountNo);

	List<AccountDO> queryByNoList(List<String> accountNoList);

	AccountDO selectForUpdateByAccountNo(String accountNo);

	@Update("update account set freeze_amount=#{freezeAmount.cent} where account_no = #{accountNo}")
	int updateFreeze(AccountDO accountDO);

}
